import React, { lazy } from 'react';
import { Navigate } from 'react-router-dom';
import Layout from '../layout/basicLayout';
import NoMenuLayout from '../layout/noMenuLayout';
import LoginPage from '../pages/login';

import NotFound from '../pages/notfound';
const Home = lazy(() => import('../pages/home'));
const NoAuth = lazy(() => import('../pages/noauth'));
const FirstLevelOne = lazy(() => import('../pages/firstLevelOne'));
const FirstLevelTwo = lazy(
  () => import('../pages/firstLevelTwo/secondLevelOne/index')
);
const Landing = lazy(() => import('../pages/nomenu/landing'));

const About = lazy(() => import('../pages/nomenu/about'));
export interface RouteConfig {
  path: string;
  element: React.ReactNode;
  auth: boolean;
  children?: RouteConfig[];
  redirect?: string;
}

// router 里面添加 菜单的label参数，menu 菜单直接循环这个路由表
export const routers = [
  { path: '/login', element: <LoginPage />, auth: false },
  { path: '/auth', element: <NoAuth />, auth: false },
  { path: '*', element: <NotFound />, auth: false },
  {
    path: '/',
    element: <Layout />,
    auth: true,
    children: [
      { path: '/home', element: <Home />, auth: true },
      { path: '/firstLevelOne', element: <FirstLevelOne />, auth: true },
      { path: '/firstLevelTwo', element: <FirstLevelTwo />, auth: true },
    ],
  },
  {
    path: '/nomenu',
    element: <Navigate to="/nomenu/landing" />,
  },
  {
    path: '/nomenu',
    element: <NoMenuLayout />,
    auth: false,
    children: [
      { path: '/nomenu/landing', element: <Landing />, auth: false },
      { path: '/nomenu/about', element: <About />, auth: false },
    ],
  },
];
